<template>
  <div>
    <div class="all-data">
      <div class="title">实时数据</div>
      <el-row>
        <el-col :span="8">
          <div class="item">
            <div class="img">
              <img src="@/assets/platformDetail/opt/icon_lx.png" />
            </div>
            <div>
              <span class="num">{{opt_lux&&opt_lux.val?opt_lux.val.toFixed(1):'NC'}}</span>
            </div>
            <div>照度</div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="item">
            <div class="img">
              <img src="@/assets/platformDetail/opt/icon_k.png" />
            </div>
            <div>
              <span class="num">{{cct&&cct.val?cct.val.toFixed(0):'NC'}}</span>
              <span>k</span>
            </div>
            <div>色温</div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="item">
            <div class="img">
              <img src="@/assets/platformDetail/opt/icon_ra.png" />
            </div>
            <div>
              <span class="num">{{ra&&ra.val?ra.val.toFixed(1):'NC'}}</span>
            </div>
            <div>Ra</div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="item">
            <div class="img">
              <img src="@/assets/platformDetail/opt/icon_eml.png" />
            </div>
            <div>
              <span class="num">{{eml&&eml.val?eml.val.toFixed(1):'NC'}}</span>
            </div>
            <div>EML</div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="item">
            <div class="img">
              <img src="@/assets/platformDetail/opt/icon_edi.png" />
            </div>
            <div>
              <span class="num">{{edi&&edi.val?edi.val.toFixed(1):'NC'}}</span>
              <span>lx</span>
            </div>
            <div>EDI</div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="item">
            <div class="img">
              <img src="@/assets/platformDetail/opt/icon_cs.png" />
            </div>
            <div>
              <span class="num">{{cs&&cs.val?cs.val.toFixed(3):'NC'}}</span>
            </div>
            <div>CS</div>
          </div>
        </el-col>

      </el-row>
    </div>
  </div>
</template>
<script>
import { getAllDeviceDataRealtime } from "@/api/platformManage";
export default {
  name: "overView",
  props: {
    deviceId: {
      type: String,
      default: ""
    },
    deviceName: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      eml: {
        val: 0,
        evaluate: {
          healthLevelShow: 0
        }
      },
      edi: {
        val: 0,
        evaluate: {
          healthLevelShow: 0
        }
      },
      cs: {
        val: 0,
        evaluate: {
          healthLevelShow: 0
        }
      },
      ra: {
        val: 0,
        evaluate: {
          healthLevelShow: 0
        }
      },
      //照度
      opt_lux: {
        val: 0,
        evaluate: {
          healthLevelShow: 0
        }
      },
      //色温
      cct: {
        val: 0,
        evaluate: {
          healthLevelShow: 0
        }
      },
    };
  },
  filters: {
  },
  watch: {
    deviceId(newVal) {
      this.getAllDeviceDataRealtimeFun(newVal);
    }
  },
  mounted() {
    // this.getAllDeviceDataRealtimeFun(this.deviceId);
  },
  methods: {
    getAllDeviceDataRealtimeFun(deviceId) {
      getAllDeviceDataRealtime(this.deviceId).then(res => {
        let data = res.value;
        if (JSON.stringify(data) == "{}") {
          this.cct = null;
          this.opt_lux = null;
          this.ra = null;
          this.eml = null;
          this.edi = null;
          this.cs = null;
        } else {
          this.cct = data.CCT;
          this.opt_lux = data.OPT_LUX;
          this.ra = data.RA;
          this.eml = data.EML;
          this.edi = data.EDI;
          this.cs = data.CS;
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.all-data {
  width: 100%;
  background-color: #fff;
  height: 320px;
  border-radius: 12px;
  padding: 10px 30px;
  .title {
    font-size: 16px;
    font-weight: bold;
    line-height: 21px;
    color: #0a0a0a;
  }
  .item {
    display: flex;
    align-items: center;
    flex-direction: column;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    line-height: 25px;
    color: #6c6c6c;
    margin: 12px 0;
    .img {
      height: 45px;
      display: flex;
      align-items: center;
      vertical-align: middle;
    }

    .num {
      font-size: 28px;
      font-family: DIN;
      font-weight: bold;
      line-height: 34px;
      color: #242424;
    }
  }
  .level-a {
    color: #0fc821;
  }
  .level-b {
    color: #0681ed;
  }
  .level-c {
    color: #5bb2ff;
  }
  .level-d {
    color: #ff512d;
  }
  .level-e {
    color: #ff0033;
  }
  .level-f {
    color: #ad0808;
  }
  .level-yellow {
    color: #ffc72d;
  }
}
@media screen and (max-width: 1670px) {
  .all-data {
    padding: 20px;
    .num {
      font-size: 28px;
      font-family: DIN;
      font-weight: bold;
      line-height: 34px;
      color: #242424;
    }
  }
}
@media screen and (max-width: 1440px) {
  .all-data {
    width: 100%;
    background-color: #fff;
    height: 320px;
    border-radius: 12px;
    padding: 10px 30px;
    .title {
      font-size: 16px;
      font-weight: bold;
      line-height: 21px;
      color: #0a0a0a;
    }
    .item {
      display: flex;
      align-items: center;
      flex-direction: column;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      line-height: 25px;
      color: #6c6c6c;
      margin: 12px 0;
      .img {
        height: 45px;
        display: flex;
        align-items: center;
        vertical-align: middle;
      }

      .num {
        font-size: 20px;
        font-family: DIN;
        font-weight: bold;
        line-height: 34px;
        color: #242424;
      }
    }
  }
}
</style>
